//
// Description: 447. 回旋镖的数量
// Created by Loading on 2021/9/13.
//

#include <bits/stdc++.h>

using namespace std;

int numberOfBoomerangs(vector<vector<int>> &points) {
    int res = 0;

    for (auto &v1 : points) {
        // 距离平方，次数
        unordered_map<int, int> m;
        for (auto &v2 : points) {
            int dis = pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2);
            m[dis]++;
        }
        for (auto &[_, cnt] : m) {
            // 需要考虑元组顺序，所以无需除以 2
            res += cnt * (cnt - 1);
        }
    }

    return res;
}

int main() {
    vector<vector<int>> points = {{0, 0},
                                  {1, 1},
                                  {2, 2}};
    int res = numberOfBoomerangs(points);
    cout << res << endl;

    return 0;
}